package y23.Aug;

class MyThread extends Thread{
    @Override
    public void run(){
        int i = 0;
        //这个线程就是线程的入口方法
        while(true){
            System.out.println("thread");
            try {
                Thread.sleep(500);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            i++;
        }
    }
}

public class Test1 {
    public static void main(String[] args) {
        Thread thread = new MyThread();
        //start 和run都是Thread的成员
        //run只是描述了现成的入口
        thread.start();
        while(true){
            System.out.println("main");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
